package day01;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class day {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] split = bf.readLine().split(",");
        int[][] num = new int[split.length][2];
        for (int i = 0; i < split.length; i++) {
            String[] split1 = split[i].split("-");
            num[i][0] = Integer.parseInt(split1[0]);
            num[i][1] = Integer.parseInt(split1[1]);
        }
        int[][] merge = merge(num);
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < merge.length; i++) {
            res.append(merge[i][0]).append("-").append(merge[i][1]).append(",");
        }
        res.deleteCharAt(res.length()-1);
        System.out.println(res.toString());
    }

    public static int[][] merge(int[][] intervals) {
        if (intervals.length == 0)
            return new int[0][];
        Arrays.sort(intervals, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o1[0], o2[0]);
            }
        });
        int l = intervals[0][0], r = intervals[0][1];
        List<int[]> t = new ArrayList<>();
        for (int i=1; i<intervals.length; i++){
            if (intervals[i][0] <= r){
                r = Math.max(r, intervals[i][1]);
            } else {
                t.add(new int[]{l, r});
                l = intervals[i][0];
                r = intervals[i][1];
            }
        }
        t.add(new int[]{l, r});
        int[][] ans = new int[t.size()][2];
        for (int i=0; i<t.size(); i++)
            ans[i] = t.get(i);
        return ans;
    }
}

